package com.kun.util;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;
/**
 * 密码MD5加密
 * */
public class MD5ProducterUtil {
	
	public static String generate(String password,String saltString){
		String hashAlgorithmName = "MD5";
	  	Object credentials = password;
	    Object salt = ByteSource.Util.bytes(saltString);
	    int hashIterations = 1024;
  	    Object result = new SimpleHash(hashAlgorithmName,credentials,salt,hashIterations);
		return result.toString();
	}
	
	public static void main(String[] args) {
  	  String hashAlgorithmName = "MD5";
  	  Object credentials = "123456";
  	  Object salt = ByteSource.Util.bytes("zhangsan"+"as526983ds");
  	  System.out.println("salt:"+salt);
  	  int hashIterations = 1024;
  	  Object result = new SimpleHash(hashAlgorithmName,credentials,salt,hashIterations);
	      System.out.println(result);
	      System.out.println(result.toString().length());
    }

}
